<?php namespace Home\Controller; 

//测试控制器
class IndexController extends CommonController{

	//构造函数
	public function __init()
	{

		
	}
	
    //动作
    public function index(){
//		用户数据
		$usermodel = new \Home\Model\User;
		if(isset($_SESSION['uid'])||isset($_SESSION['username'])){
			$userdata = $usermodel->where("username='{$_SESSION['username']}'")->find();
			View::with('userdata',$userdata);
		}
//		首页设置
		$setindex = Db::table('setting')->get();
		//分配数据
		View::with('setindex',$setindex);
		
//		分类数据
		$catemodel = new \Home\Model\Cate;
//		全部
		$catedata = $catemodel->get();
		View::with('catedata',$catedata);
//		顶级分类
		$catedatatop = $catemodel->where("pid=0")->get();
		View::with('catedatatop',$catedatatop);
//		和首页设置关联
		$catedata_setindex = $catemodel->join('setting','cid','=','stcid')->get();
		View::with('catedata_setindex',$catedata_setindex);
		
       	View::make();
    }
}
